import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/entity/_.dart';

class BannerWidget extends StatelessWidget{

 final List<BannerItem> bannerData ;

 BannerWidget({required this.bannerData});

  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
        child: Swiper(
          outer:false,
          onTap: (int index){
            Modular.to.pushNamed('/thinkInfo/${bannerData[index].bannerContentId!}/${bannerData[index].bannerType!}');
          },
          autoplay: true,
          itemBuilder: (BuildContext c, int i) {
            return ClipRRect(
              borderRadius: BorderRadius.all(Radius.circular(10)),
              child:Container(
                decoration: BoxDecoration(
                    image: DecorationImage(
                        image: NetworkImage(
                          bannerData[i].bannerUrl!,

                        ),
                        fit: BoxFit.cover
                    )
                ),
                child: Align(
                  alignment:Alignment(-0.8,-0.8),
                  child: Text(
                    bannerData[i].bannerValue!,
                    style: TextStyle(
                      color: ColorConfig.WhiteBackColor,
                      fontSize: 17,
                      fontWeight: FontWeight.bold,

                    ),
                  ),
                ),
              ),

            );
          },
          pagination: SwiperPagination(
              builder: DotSwiperPaginationBuilder(
                  color: ColorConfig.WhiteBackColor,
                  activeColor: ColorConfig.ThemeColor

              )
          ),
          viewportFraction: 0.8,
          scale: 0.8,
          itemCount: bannerData.length,

        ),

        constraints:BoxConstraints.loose(Size.fromHeight(170))
    );
  }

}